<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回错误代码的字符串描述</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.curl-strerror" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_strerror</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7)</p><p class="refpurpose"><span class="refname">curl_strerror</span> &mdash; <span class="dc-title">返回错误代码的字符串描述</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.curl-strerror-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>curl_strerror</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$errornum</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   返回文本错误信息，解释了指定的错误代码。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.curl-strerror-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<code class="parameter">errornum</code></dt>

    <dd>

     <p class="para">
      <a href="http://curl.haxx.se/libcurl/c/libcurl_errors.html" class="link external">&raquo;&nbsp;cURL 错误代码</a>中的常量之一。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.curl-strerror-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回错误信息描述，无效的错误代码返回 <strong><code>NULL</code></strong> 。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.curl-strerror-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5257">
    <p><strong>Example #1 <span class="function"><a href="curl_errno.html" class="function">curl_errno()</a></span> 函数的范例：</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;a&nbsp;curl&nbsp;handle&nbsp;with&nbsp;a&nbsp;mispelled&nbsp;protocol&nbsp;in&nbsp;URL<br /></span><span style="color: #0000BB">$ch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">(</span><span style="color: #DD0000">"htp://example.com/"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Send&nbsp;request<br /></span><span style="color: #0000BB">curl_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Check&nbsp;for&nbsp;errors&nbsp;and&nbsp;display&nbsp;the&nbsp;error&nbsp;message<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$errno&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$error_message&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_strerror</span><span style="color: #007700">(</span><span style="color: #0000BB">$errno</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"cURL&nbsp;error&nbsp;(</span><span style="color: #007700">{</span><span style="color: #0000BB">$errno</span><span style="color: #007700">}</span><span style="color: #DD0000">):\n&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$error_message</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Close&nbsp;the&nbsp;handle<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
cURL error (1):
 Unsupported protocol
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.curl-strerror-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="curl_errno.html" class="function" rel="rdfs-seeAlso">curl_errno()</a> - 返回最后一次的错误代码</span></li>
    <li class="member"><span class="function"><a href="curl_error.html" class="function" rel="rdfs-seeAlso">curl_error()</a> - 返回当前会话最后一次错误的字符串</span></li>
    <li class="member"><a href="http://curl.haxx.se/libcurl/c/libcurl_errors.html" class="link external">&raquo;&nbsp;Curl error codes</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>